<?

//first show all courses 
//if something is selected, list all participants
//link users to "bezahlt" status

if(isset($_GET['pid'])){

	$pid =$_GET['pid'];
	echo "Export als <a href=\"?id=csv&action=teilnehmer&pid=".$_GET['pid']."\">csv</a><br>";
	echo "Email an alle Teilnehmer <a href=\"?id=rundmail&pid=".$_GET['pid']."\">schicken</a><br>";
	
	$query = "SELECT id as 'ID', name as 'Titel' FROM`2011_veranstaltung` WHERE id = '$pid'";	
	$result = doQuery($query);
	$array = mysql_fetch_assoc($result);
	echo "<h1>".$array['Titel']."</h1>";
	$query = "SELECT 2011_hoert.sch_id as 'Benutzer ID' ,2011_schueler.name as 'Name',2011_schueler.vname as 'Vorname', 2011_hoert.paid as 'Bezahlt' FROM `2011_hoert`, 2011_schueler WHERE 2011_hoert.sch_id = 2011_schueler.id AND 2011_hoert.ver_id = '".$pid."' ORDER BY 2011_schueler.name";		
	$result = doQuery($query);
	$array = mysql_fetch_assoc($result);
	if($array == false){
		echo "Keine Teilnehmer!";
	}
	else{
	echo getTableHead($array);
	while($array !== false){
		$array['Benutzer ID'] = "<a href='?id=bezahlt&pid=".$array['Benutzer ID']."'>".$array['Benutzer ID']."</a>";
		echo getTableContent($array);
		
		$array = mysql_fetch_assoc($result);
	}
	echo getTableEnd();	
	
	}

}



	$query = "SELECT id as 'ID', name as 'Titel' FROM`2011_veranstaltung`";
	$result = doQuery($query);
	$array = mysql_fetch_assoc($result);
	$array_init = $array;
	
	echo "<form action='?id=".$_GET['id']."' method='POST'>";
	echo "<input type=\"hidden\" name=\"pid\"    value=\"".$pid."\" />";
	echo getTableHead($array);
	while($array !== false){
	$array['Titel'] = "<a href='?id=teilnehmer&pid=".$array['ID']."'>".$array['Titel'] ."</a>";
		echo getTableContent($array);
		$array = mysql_fetch_assoc($result);
	}
	echo getTableEnd();	
	echo "</form>";
	

?>